<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<TITLE>WorkFlow Tree</TITLE>
<META name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<META name="CODE_LANGUAGE" Content="C#">
<META name="vs_defaultClientScript" content="JavaScript">
<META name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<?XML:NAMESPACE PREFIX="MYTREE">
<?XML:NAMESPACE PREFIX="WM">
<?XML:NAMESPACE PREFIX="DIMOK">
<?IMPORT NAMESPACE="MYTREE" IMPLEMENTATION="/include/HTC/TreeEx/treeex.htc" >
<?IMPORT NAMESPACE="WM"     IMPLEMENTATION="/Include/HTC/dropmenu.htc" >
<?IMPORT namespace="DIMOK" implementation="/include/htc/datagrid.htc">
<LINK rel="stylesheet" type="text/css" href="/CSS/Outlook.css">
<LINK rel="stylesheet" type="text/css" href="/CSS/navbar.css">
<SCRIPT src="/Include/common.js"></SCRIPT>
<STYLE>
.SF{FONT-SIZE: smaller}
</STYLE>
</HEAD>
<BODY MS_POSITIONING="GridLayout" bgcolor="" onclick="showMenus()" onkeypress="if(event.keyCode==27)treeWorkFlow.selectedNodeIndex='100000'">
<TABLE><TR valign="top"><TD>
<DIV style="BEHAVIOR: url(/Include/HTC/Toggle.htc)"><LABEL></LABEL></DIV>
<DIV>
<INPUT onchange="treeWorkFlow.showByAttrs(null,{'text':this.value})"> Find<BR>
<SELECT id="selNSs" runat="server" onchange="WF_Tree();WF_List()"></SELECT> Status<BR>
<SELECT id="selGroups" runat="server" onchange="WF_Tree()"></SELECT> Groups
<DIV style="width:100%;height:100%;overflow:auto">
<MYTREE:TREEVIEWEX id="treeWorkFlow" SELECTEDNODEINDEX="100000" SYSTEMIMAGESPATH="/webctrl_client/1_0/TreeImages/"
	SHOWPLUS="true" EXPANDLEVEL="0" DEFAULTSTYLE="FONT-WEIGHT: bold; FONT-FAMILY: menu;"
	onnodebound="" onclick="setTimeout(function(){showActions()},100)" oncontextmenu="return showMenu(this)"
	NODESTATEATTRIBUTE="tabID" syncdatabind="XXX"
>
	<MYTREE:TREENODETYPE TYPE="N" DEFAULTSTYLE="COLOR:#003399" />
	<ASP:LITERAL ID="ltrWFTree" Runat="server"></ASP:LITERAL>
</MYTREE:TREEVIEWEX>
</DIV>
</DIV>
	<TD>
<TABLE datasrc="#xmlActions" wsMethod="WF_Actions_Update" style="">
	<THEAD><TR><TH>Pos</TH><TH>Menu From</TH><TH>Menu To</TH><TH>Action</TH></TR></THEAD>
	<TR valign="top">
		<TD><INPUT  datafld="Pos" size="2" onchange="return UF_Action(this)" class="SF"></TD>
		<TD><SELECT datafld="MenuFromID" null onchange="return UF_Action(this)" id="selMenusFrom" runat="server" class="SF"></SELECT></TD>
		<TD><SELECT datafld="MenuToID" null onchange="return UF_Action(this)" id="selMenusTo" runat="server" class="SF"></SELECT></TD>
		<TD><TEXTAREA datafld="Action" onchange="return UF_Action(this)" style="overflow:visible;width:100%" class="SF"></TEXTAREA></TD>
		<TD><INPUT type="button" onclick="WF_Actions_Delete(this)" value="X" title="Delete Action" class="SF"></TD>
	</TR>
</TABLE>
</TABLE>
<TABLE height="100%" width="100%">
	<TR height="80%">
		<TD>
			<DIMOK:HTCDATAGRID id="dtgIncomplete" caption="Menus" allowEdit="true" allowAdd="true" allowDelete="true"
				style="width:100%;height:100%;overflow-x:auto;overflow-y:visible" hiddenFields="" onDelete="deleteRec()"
				onEdit="editRec()" onAdd="addRec()"
				onFilter="Menu_List(this)"
				>
				<RS>
					<ASP:LITERAL ID="ltrMenus" Runat="server"></ASP:LITERAL>
				</RS>
			</DIMOK:HTCDATAGRID>
		</TD>
	</TR>
</TABLE>
<DIV id="divMenus" style="position:absolute;display:none;width:1px;BORDER:black 1px solid;COLOR: white; BACKGROUND-COLOR: #001177;" align="center" nowrap>
<SPAN id="divMenuTitle" style="BORDER: black 1px solid; FONT-WEIGHT: bold"></SPAN><BR>
<SELECT id="selMenus" runat="server" onblur="showMenus()" size="8" onchange="WF_Add(undefined,undefined,this.selectedIndex)"></SELECT>
</DIV>
<XML id="xmlActions"><ASP:LITERAL ID="ltrActions" Runat="server"></ASP:LITERAL></XML>
</BODY>
</HTML>
<SCRIPT language="javascript" src="/include/DropMenu.js"></SCRIPT>
<SCRIPT language="javascript" src="/include/Tree.js"></SCRIPT>
<SCRIPT language="javascript" src="/include/common.js"></SCRIPT>
<SCRIPT language="javascript" src="/include/SOAP.js"></SCRIPT>
<SCRIPT language="javascript" src="/include/XML.js"></SCRIPT>
<SCRIPT language="javascript" src="/include/RDS.js"></SCRIPT>
<SCRIPT language="javascript" src="Common/Admin.js"></SCRIPT>
<SCRIPT id="Menu">
function Menu_List(dtg){
	var filter = (event.rs.filter||"").replace(/[*]/g,"%");
	var ret = WS(CO(),encodeXML(filter));
	if( showSOAPError(ret) )return false;
	dtg.setRecordset(ret.value);
}
function deleteRec(){
	if( !checkWS() || !confirm("Delete Record?") )event.returnValue = false;
	var ret = WS(CO("Menu_Delete"),_ID());
	if(showSOAPError(ret)) return event.returnValue = false;
	WF_List();
}
function editRec(){
	if(!checkWS()) event.returnValue = false;
	var ret = WS(CO("Menu_Update"),_ID(),event.fieldName,event.fieldValue);
	if(showSOAPError(ret)) return event.returnValue = false;
	WF_List();
}
function addRec(){
	if(!checkWS()) event.returnValue = false;
	var ret = WS(CO("Menu_Add"),getDSFromRS(event.rs,"xmlProgram"));
	if( showSOAPError(ret) )return event.returnValue = false;
	_ID(ret.value);
	WF_List();
}
function _ID(id){
	var idName = "MenuID";
	if( arguments.length )event.rs(idName).value = id;
	return event.rs(idName).value;
}
</SCRIPT>
<SCRIPT id="WorkFlow" language="javascript">
var u;
function hideSelects(show,selExlude){
	var sels = document.all.tags("SELECT");
	for( var i=0; i < sels.length; i++ )
		if( sels[i] != selExlude )sels[i].style.visibility = show ? 'visible' : 'hidden';
}
function showActions(){
	var node = treeWorkFlow.getNodeFromIndex();
	if( !node )return;
	var ret = WS(CO("WF_Actions"),node.id);
	if( showSOAPError(ret) )return;
	xmlActions.loadXML(ret.value);
}
function UF_Action(el){
	var conf = el.tagName.match(/(INPUT|TEXTAREA)/) ? el.value : el[el.selectedIndex].text;
	if( !confirm("Change "+el.dataFld+" to:\n"+conf) ){
		if( el.tagName == "SELECT" )el.value = rsField(el,"MenuFromID").value;
		return false;
	}
	var ret = UF(u,u,u,u,rsField(el,"EventID").value||0);
	if( !ret || !ret.value )return;
	xmlActions.loadXML(ret.value);
}
function WF_Actions_Delete(el){
	if( !confirm("Delete ["+rsField(el,"MenuPathFrom")+"]->["+rsField(el,"MenuPathTo")+"]=["+rsField(el,"Action")+"]") )return;
	var ret = WS(CO(),rsField(el,"EventID").value);
	if( showSOAPError(ret) )return;
	xmlActions.recordset.Delete();
}
function WF_List(){
	var ret = WS(CO(),selNSs.value);
	if( showSOAPError(ret) )return;
	fillSelect(ret.value,selMenus,"MenuPath","MenuID");
}
function WF_Tree(){
	var ret = WS(CO(),selNSs.value,selGroups.value);
	if( showSOAPError(ret) )return;
	databind(ret.value);
}
function WF_Add(fromID,fromText,selIndex){
	if( typeof(selIndex) == "undefined" ){
		WF_Add.fromID = fromID; WF_Add.fromText = fromText;
		var x = event.clientX;
		var y = event.clientY;
		return setTimeout(function(){showMenus(x,y,"... -> Path To")},100);
	}
	if( !confirm("Add path ["+WF_Add.fromText+"] => ["+selMenus[selMenus.selectedIndex].text+"]") )return;
	var grantAccess = confirm("Grant access to "+selGroups.value);
	var ret = WS(CO(),WF_Add.fromID,selMenus.value,selGroups.value,grantAccess);
	if( !ret ){
		alert("Web page error!\nMust reload now.");
		return location.reload();
	}
	if( showSOAPError(ret) )return;
	databind(ret.value);
}
function WFG_Add(parentID,kidID,parentText,kidText){
	if( !confirm("Grant access to path ["+parentText+"] => ["+kidText+"] to group ["+selGroups.value+"]?") )return;
	var ret = WS(CO(),parentID,kidID,selGroups.value);
	if( showSOAPError(ret) )return;
	databind(ret.value);
}
function WF_Rem(parentID,kidID,parentText,kidText){
	if( !confirm("Get rid of path ["+parentText+"] => ["+kidText+"]?") )return;
	var ret = WS(CO(),parentID,kidID,selGroups.value);
	if( showSOAPError(ret) )return;
	databind(ret.value);
}
function WFG_Rem(parentID,kidID,parentText,kidText){
	if( !confirm("Revoke access to path ["+parentText+"] => ["+kidText+"] for group ["+selGroups.value+"]?") )return;
	var ret = WS(CO(),parentID,kidID,selGroups.value);
	if( showSOAPError(ret) )return;
	databind(ret.value);
}
function showMenu(el){
	var dm = new DropMenu("mnuFly");
	if( !dm.menuID )return false;
	if( event.treeNodeIndex === undefined )return;
	var node = el.getTreeNode(event.treeNodeIndex);
	var kidText = node.getNode().text;
	var kidID = node.getNode().id;
	var parentNode = node.getParent();
	if( parentNode ){
	
		var parentText = parentNode.getNode().text;
		var parentID = parentNode.getNode().id;
		dm.add("Add Access To Path","WFG_Add("+parentID+","+kidID+",\""+parentText+"\",\""+kidText+"\")","/Images/Tree_Little.gif");
		dm.add("Remove Access To Path","WFG_Rem("+parentID+","+kidID+",\""+parentText+"\",\""+kidText+"\")","/Images/KeyPress.gif");
		dm.add("Remove Path","WF_Rem("+parentID+","+kidID+",\""+parentText+"\",\""+kidText+"\")","/Images/KeyPress.gif");
	}
	dm.add("Add New Path","WF_Add("+kidID+",\""+kidText+"\")","/Images/Tree_Little.gif");
	dm.menuShow();
	event.cancelBubble = true;
	return false;
}
function showMenus(x,y,title){
	if( !arguments.length ){
		hideSelects(true,selMenus);
		return divMenus.style.display = 'none';
	}
	divMenus.style.display = ""
	divMenus.style.posLeft = x;
	divMenus.style.posTop = y;
	divMenuTitle.innerHTML = title;
	selMenus.value = null;
	hideSelects(false,selMenus);
}
function databind(xml){
	treeWorkFlow.treeNodeSrc = transformTreeNodesToSrc(xml);
	treeWorkFlow.databind();
}
</SCRIPT>
